import axios from 'axios';
import router from '../router'

let url_root = 'http://127.0.0.1:8082'
// let url_root = ''

let http={}

http.post = function(url,params,success){
    params.token = localStorage.token;

	axios.post(url_root+url,params)
    .then(function (res) {
        console.log(res)
        if(res.data.errorCode=='-1'){
            router.push({path:'/login'})
            alert(res.data.msg);
        }
    	success(res.data)
    })
    .catch(function (error) {
        console.log(error);
    });
}



export default http